<?php
namespace App\Module\Admin\Service;

use App\Model\Roll;
use App\Module\Admin\Request\Roll\CreateRequest;
use App\Module\Admin\Request\Roll\UpdateRequest;

class RollService{

    public function search($pagesize){
        return Roll::query()->latest("roll_id")->paginate($pagesize);
    }

    public function create(CreateRequest $request){
        $model = new Roll();
        $model->fill($request->all());
        return $model->save();
    }

    public function getById($id){
        return Roll::query()->find($id);
    }

    public function update(UpdateRequest $request,$id){
        $model = Roll::query()->findOrFail($id);
        $model->fill($request->all());
        return $model->save();
    }

    public function delete($id){
        return Roll::destroy($id);
    }
}